#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
using namespace std;
  struct TreeNode {
 	int val;
 	struct TreeNode *left;
 	struct TreeNode *right;
 	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
  };
 
class Solution {
public:
    void _PreOrder(TreeNode* root, vector<int>& v)
    {
        if (root == nullptr)
        {
            return;
        }
        v.push_back(root->val);
        _PreOrder(root->left, v);
        _PreOrder(root->right, v);
    }
    vector<int> preorderTraversal(TreeNode* root)
    {
        vector<int> ret;
        _PreOrder(root, ret);
        return ret;
    }
};